package com.itheima.mapper;

import com.github.pagehelper.Page;
import com.itheima.pojo.Clazz;
import com.itheima.pojo.ClazzQueryParam;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @version 1.0
 * @description 说明
 * @package com.itheima.mapper
 */
@Mapper
public interface ClazzMapper {

    /**
     * clazzMapper
     * @return
     */
    @Select("select * from clazz")
    List<Clazz> selectAll();

    /**
     * 新增班级
     * @param clazz
     */
    @Insert("insert into clazz(name,room,begin_date,end_date,master_id,subject,create_time,update_time) values(#{name},#{room},#{beginDate},#{endDate},#{masterId},#{subject},#{createTime},#{updateTime})")
    void insert(Clazz clazz);

    /**
     * 分页查询班级
     * @param clazzQueryParam
     * @return
     */
    Page<Clazz> pageQuery(ClazzQueryParam clazzQueryParam);

    /**
     * 通过id删除
     * @param id
     */
    @Delete("delete from clazz where id=#{id}")
    void deleteById(Integer id);

    /**
     * 通过id查询
     * @param id
     * @return
     */
    @Select("select * from clazz where id=#{id}")
    Clazz selectById(Integer id);

    void updateById(Clazz clazz);
}
